<template>
    <div>
        {{ copd }}
        会员名称:
        <input type="text" v-model="copd.name" >
        会员等级:
        <select v-model="copd.did">
                            <option value="">请选择</option>
                            <option :value="o.dId" v-for="o in find">{{ o.name }}</option>
                        </select>
                        <input type="button" value="查询" @click="Show" >
        <table class="table table-bordered ">
            <thead>
                <tr>
                    <td>会员编号</td>
                    <td>会员姓名</td>
                    <td>会员号码</td>
                    <td>身份号</td>
                    <td>会员生日</td>
                    <td>会员性别</td>
                    <td>会员爱好</td>
                    <td>会员等级</td>
                    <td>会员积分</td>
                    <td>会员余额</td>
                    <td>会员简介</td>
                    <td>状态</td>
                    <td>功能</td>
                </tr>

                <tr v-for="o in info" :key="o.id" >
                    <td>{{ o.number }}</td>
                    <td>{{ o.dName }}</td>
                    <td>{{ o.phone }}</td>
                    <td>{{ o.shfn }}</td>
                    <td>{{ moment(o.data).format("yyyy-MM-DD") }}</td>
                    <td>{{ o.dSex==1?"男":"女" }}</td>
                    <td>{{ o.ai }}</td>
                    <td>{{ o.name }}</td>
                    <td>{{ o.fen }}</td>
                    <td>{{ o.money }}</td>
                    <td>{{ o.text }}</td>
                    <td>{{ o.state==1?"禁用":"启用" }}</td>
                    <td>
                        <input type="button" v-if="o.state==0" value="禁用" @click="Update(o.id,1)" >
                        <input type="button" v-if="o.state==1" value="启用" @click="Update(o.id,0)" >
                        <input type="button" value="修改" @click="Dataa(o.id)" ></td>
                </tr>
            </thead>
        </table>
    </div>
</template>

<script setup lang="ts">
import axios from 'axios';
import moment from 'moment';
import { idText } from 'typescript';
import { onMounted, ref } from 'vue';
import { useRouter } from 'vue-router';

const router=useRouter();

let info:any=ref([]);

let find: any = ref([]);

let copd:any=ref({
    name:'',
    did:''
});

onMounted(()=>{
    List();
    Show();
})

const Show=()=>{
    axios({
        url:'https://localhost:7033/api/User/Show',
        method:'get',
        params:copd.value
    })

    .then((res)=>{
        console.log(res);
        info.value=res.data
    })
}



const List = () => {

    axios({
        url: 'https://localhost:7033/api/User/Luist',
        method: 'get',
    })
        .then((res) => {
            console.log(res);
            find.value = res.data
        })
}

const Dataa=(id:any)=>{
    router.push({
        path:'/fandUp',
        query:{
            id:id
        }
    })
    .then((res)=>{
        console.log(res);
        
    })
}


const Update=(id:any,state:any)=>{
    let f=confirm("要修改吗")
    if(f){
        axios({
            url:'https://localhost:7033/api/User/Updata',
            method:"post",
            params:{
                id:id,
                strate:state
            }
        })
        .then((res)=>{
            console.log(res);
            if(res.data>0)
        {
            alert("修改成功");
            Show();
        }
        else
        {
            alert("失败");
        }
        } )
    }
}


</script>

<style scoped>

</style>